package com.gitee.wsl.common.ui.symbol.particle

import androidx.compose.ui.graphics.Color
import com.gitee.wsl.common.ui.base.Vector2D

open class SpeedParticle(
    startX: Float = 0f,
    startY: Float = 0f,
    var radius: Float = 0f,
    val speed:Vector2D=Vector2D(),
    val randomSpeed:Vector2D=Vector2D(),
    size: Float = 5f,
    color: Color = Color.Red,
    alpha: Float = 1f
):Particle(startX, startY, size, color,alpha){


    fun update():Boolean {
        this.randomSpeed.x = getRandomRange(-0.001f, 0.001f);
        this.randomSpeed.y = getRandomRange(0.01f, 0.02f);
        this.speed.x += this.randomSpeed.x;
        this.speed.y += this.randomSpeed.y;
        this.startX += this.speed.x;
        this.startY += this.speed.y;

        if (this.radius >= 0.01f) {
            this.radius -= 0.2f;
            this.alpha -= 0.001f;
            return true;
        }
        this.radius = 0f;
        this.alpha = 0f;
        return false;
    }

}